Frontend Forever App
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it now
Intall Later
Run
HTML
CSS
Javascript
Output
Document
@charset "UTF-8"; @import url(https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800); *, :after, :before { box-sizing: border-box; padding: 0; margin: 0; } body { margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background-color: darkseagreen; } :root { --font-size: 40px; } .toggle { position: absolute; width: 10em; height: 5em; font-size: var(--font-size); margin: 0; filter: opacity(0); cursor: pointer; z-index: 2; } .toggle ~ .switch { position: absolute; width: 10em; height: 5em; font-size: var(--font-size); background: linear-gradient(silver, whitesmoke); border-radius: 2.5em; display: flex; align-items: center; justify-content: center; } .toggle ~ .switch .inner { width: 8em; height: 3.5em; background: linear-gradient(dimgray, silver); border-radius: 2em; box-shadow: inset 0 0 1.5em rgba(0, 0, 0, 0.5); display: flex; justify-content: center; } .toggle ~ .switch .inner .disc { width: 3.5em; height: 3.5em; background: linear-gradient(to top, silver, whitesmoke); border-radius: 50%; box-shadow: 0 0.4em 0.6em rgba(0, 0, 0, 0.2); position: relative; left: -30%; display: flex; align-items: center; justify-content: center; transition: 0.5s; } .toggle ~ .switch .inner .disc::before { content: 'OFF'; position: absolute; width: 80%; height: 80%; background: linear-gradient(silver, whitesmoke); border-radius: 50%; text-align: center; line-height: calc(3.5em * 0.8); font-family: sans-serif; color: gray; } .toggle:checked ~ .switch .inner { background: linear-gradient(green, limegreen); } .toggle:checked ~ .switch .inner .disc { left: 30%; } .toggle:checked ~ .switch .inner .disc::before { content: 'ON'; color: limegreen; }
console.log("Event Fired")